-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace the IoVec struct with IoSlice and IoSliceMut from the standard library #1643
Conversation
Checks appear to be failing because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget a CHANGELOG, too!
src/sys/sendfile.rs
Outdated
@@ -68,24 +68,24 @@ cfg_if! { | |||
target_os = "freebsd", | |||
target_os = "ios", | |||
target_os = "macos"))] { | |||
use crate::sys::uio::IoVec; | |||
use std::io::IoSlice; | |||
|
|||
#[derive(Clone, Debug, Eq, Hash, PartialEq)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is causing failures, because IoSlice doesn't implement some of these traits. But SendfileHeaderTrailer
isn't pub
, so there's no penalty to remove some of its trait impls. What happens if you remove the offending trait impls? If it breaks something else, then you'll probably have to manually implement them, rather than derive them.
src/sys/uio.rs
Outdated
@@ -88,7 +98,7 @@ pub fn pread(fd: RawFd, buf: &mut [u8], offset: off_t) -> Result<usize>{ | |||
/// A slice of memory in a remote process, starting at address `base` | |||
/// and consisting of `len` bytes. | |||
/// | |||
/// This is the same underlying C structure as [`IoVec`](struct.IoVec.html), | |||
/// This is the same underlying C structure as `IoVec`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// This is the same underlying C structure as `IoVec`, | |
/// This is the same underlying C structure as `IoSlice`, |
The CI errors appear to be due to a clippy error unrelated to this pull request. |
I don't think so. I think those errors were introduced by this PR. nmount uses IoVec/IoSlice. |
Remainder of CI failures appear to be due to the aforementioned clippy error |
The ptrace warning is fixed in master. You need to rebase. |
Is there anything else that I need to do here before I can merge this request? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the slow response, I've been working on other things lately. This looks 99% good; I just have a few comments about nmount.
@@ -371,19 +371,27 @@ impl<'a> Nmount<'a> { | |||
pub fn nmount(&mut self, flags: MntFlags) -> NmountResult { | |||
// nmount can return extra error information via a "errmsg" return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment got separated from the code it describes. It should be directly above line 380.
src/mount/bsd.rs
Outdated
|
||
// N.B. notgull: the last entry here is technically an IoSliceMut. | ||
// this is a workaround to keep soundness in place | ||
let mut iovecs: Vec<libc::iovec> = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing a const transmutation, should self.iov be a vec of IoSliceMut instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. nmount
's methods by default takes several immutable pointers. Maybe we could just make it a list of libc::iovec
by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the problem is that the C API isn't const-correct. All of nmount's arguments are supposed to be const, except for the errmsg argument. So a transmutation like you had is probably Nix's best option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess whether you do a mem::transmute or a pointer cast, it's equally ugly, and it's C's fault. This PR looks almost good to me, but I suggest getting rid of the #[inline]
on private methods.
src/mount/bsd.rs
Outdated
} | ||
|
||
#[cfg(target_os = "freebsd")] | ||
#[cfg_attr(docsrs, doc(cfg(all())))] | ||
impl<'a> Nmount<'a> { | ||
/// Helper function to push a slice onto the `iov` array. | ||
#[inline] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to specify #[inline]
for private methods.
Could you please rebase? You've got some conflicts now, and a rebase will also fix the test failure on uclibc. |
@notgull are you sure you rebased to the current master? It doesn't look like it. |
Should this be blocking the 0.24 release? It'd be nice to have the feature splits out the door. |
@asomers will you have a chance to look at this in the next week or so? If not I can take a look; I agree with @SUPERCILEX that it'd be nice to get a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It LGTM, apart from a few minor nits.
Ok, it looks like you've made all requested changes and the tests pass. Would you please squash now? Then we'll merge it. |
Squashed and ready to rumble! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+
Thanks everyone for helping get 0.24 out! :) |
As per discussion in #1637, the
IoVec<&[u8]>
andIoVec<&mut [u8]>
types have been replaced withstd::io::IoSlice
andIoSliceMut
, respectively. Notable changes made in this pull request include:IoVec
withIoSlice*
types in both public API, private API, and tests.IoVec
withIoSlice
in docs.&[IoVec<&mut [u8]>]
with&mut [IoSliceMut]
, note that the slice requires a mutable reference now. This is how it's done in the standard library, and there might be a soundness issue in doing it the other way.Resolves #1637